function jcb_contourplot(x,y,z)

if nargin < 3
    if nargin==1
        z=x;
        y=1:size(z,1);
        x=1:size(z,2);
        warning('jcb_contourplot:NotEnoughArguments','x and y vectors were not supplied, using indices instead');
    else
        y=1:10;
        x=1:15;
        z=magic(max(length(x),length(y)));
        z=z(1:length(x),1:length(y));
        warning('jcb_contourplot:NotEnoughArguments','not enough arguments given, so data has been made up');
    end    
end

if sum(size(x)>1)==1
    if sum(size(y)>1)==1
        [mX mY]=meshgrid(x,y);
    else
        error('x and y have different number of dimensions');
    end
else
    mX=x;
    mY=y;
end

if size(z,1)==size(mX,2) && size(z,2)==size(mY,1)
    z=z';
end

if ~(size(mX,1)==size(z,1) && size(mX,2)==size(z,2) && ...
     size(mY,1)==size(z,1) && size(mY,2)==size(z,2))
        error('Matrix dimensions must agree.');
end

pcolor(mX,mY,z);

colorbar;
shading flat;
axis equal;
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
colormap(jet(512));
return